import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
  BeforeInsert,
} from 'typeorm';
export type GeoJsonType = 'line' | 'fill' | 'symbol';
@Entity()
export class Geojson {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column()
  creator: string;

  @Column()
  file_id: string;

  @Column({ default: false })
  noteSwitch: boolean;

  @Column({
    type: 'timestamp without time zone',
    default: () => 'CURRENT_TIMESTAMP',
  })
  create_time: Date;

  @UpdateDateColumn({
    type: 'timestamp without time zone',
    default: () => 'CURRENT_TIMESTAMP',
  })
  update_time: Date;

  @Column()
  start: number;

  @Column()
  finish: number;

  @Column({
    type: 'enum',
    enum: ['line', 'fill', 'circle'],
    default: 'line',
  })
  type: GeoJsonType;

  @Column()
  keepLive: boolean;

  @Column({ default: '' })
  animation: string;

  @Column('simple-json', { default: '{}' })
  filter: object;

  @Column('simple-json', { default: '{}' })
  paint: object;

  @Column('simple-json', { default: '{}' })
  layout: object;

  // 标识场景实例的使用的file_id 是公共资源的还是用户资源的
  @Column('enum', { enum: ['user', 'public'], default: 'user' })
  resource_type: string;
}
